var redis=require('../redis/index.js')
var config=require('../../config.js')
module.exports=function(req){
	return new Promise(async (resolve,reject)=>{		
		var query=req.query;
		var token=req.headers['x-token-shitian'] || null;
		//是否有token参数
		if(token){
			token=await redis.get(token)
		}
	  //是否登陆
		if(token == null){
			resolve(false)
			return;
		};
		var tokenIp=token.split('-')[4]||[];
		var ip=req.headers['origin'] || Math.random();
	
		if(config.FriendvFisit){
			resolve(true);
		}
		//是否为其他机器发出的
		if(tokenIp == ip){    
			resolve(true);
		}
		resolve(false)
	})
}